<template>
	<view class="index-list animated fadeInLeft fast">
		<view class="index-list1">
			<view>
				<image :src="item.userpic" mode="widthFix" lazy-load></image>
				{{item.username}}
			</view>
			<view v-show="!isguanzhu" @click="guanzhu">
				<view class="icon iconfont icon-zengjia"></view>关注
			</view>
		</view>
		<view class="index-list2" @click="opendetail">{{item.title}}</view>
		<view class="index-list3 u-f-ajc" @click="opendetail">
			<!-- 图片 -->
			<image :src="item.titlepic" mode="widthFix" lazy-load></image>
			<template v-if="item.type==='video'">
				<!-- 视频 -->
				<view class="icon iconfont icon-bofang index-list-play "></view>
				<view class="index-list-playinfo">
					{{item.palynum}}次播放 {{item.long}}
				</view>
			</template>
		</view>
		<view class="index-list4">
			<view>
				<view :class="{'active':infonum.index===1}" @click="caozuo('ding')">
					<view class="icon iconfont icon-icon_xiaolian-mian"></view>
					{{infonum.dingnum}}
				</view>
				<view :class="{'active':infonum.index===2}" @click="caozuo('cai')">
					<view class="icon iconfont icon-kulian"></view>
					{{infonum.cainum}}
				</view>
			</view>
			<view>
				<view>
					<view class="icon iconfont icon-pinglun1"></view>
					{{item.commentnum}}
				</view>
				<view>
					<view class="icon iconfont icon-zhuanfa"></view>
					{{item.sharenum}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isguanzhu:this.item.isguanzhu,
				infonum:this.item.infonum
			}
		},
		props: {
			item: Object,
			index: Number
		},
		methods: {
			guanzhu() {
				this.isguanzhu = true;
				uni.showToast({
					title: '关注成功'
				})
			},
			caozuo(type) {
				switch (type) {
					case "ding":
						if (infonum.index == 1) {
							return;
						}
						infonum.dingnum++;
						if (infonum.index == 2) {
							infonum.cainum--;
						}
						infonum.index = 1
						break;
					case "cai":
						if (infonum.index == 2) {
							return;
						}
						infonum.cainum++;
						if (infonum.index == 1) {
							infonum.dingnum--;
						}
						infonum.index = 2
						break;
				}
			},
			opendetail(){
				uni.navigateTo({
					url: '../../pages/detail/detail?detailData='+JSON.stringify(this.item),
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.index-list {
		padding: 20rpx;
		border-bottom: 1rpx solid #EEEEEE;

		.index-list1 {
			display: flex;
			justify-content: space-between;
			align-items: center;

			view:first-child {
				display: flex;
				align-items: center;
				color: #999999;

				image {
					width: 85rpx;
					height: 85rpx;
					border-radius: 100%;
					margin-right: 10rpx;
				}
			}

			view:last-child {
				display: flex;
				align-items: center;
				background: #F4F4F4;
				border-radius: 5rpx;
				padding: 0 10rpx;
			}
		}

		.index-list2 {
			padding-top: 15rpx;
			font-size: 32rpx;
		}

		.index-list3 {
			padding-top: 15rpx;
			position: relative;

			image {
				width: 100%;
				border-radius: 20rpx;
			}

			.index-list-play {
				position: absolute;
				font-size: 140rpx;
				color: #FFFFFF;
			}

			.index-list-playinfo {
				position: absolute;
				background: rgba(51, 51, 51, 0.72);
				color: #FFFFFF;
				bottom: 8rpx;
				right: 8rpx;
				border-radius: 40rpx;
				font-size: 22rpx;
				padding: 0 12rpx;
			}
		}

		.index-list4 {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 15rpx 0;
			color: #999999;

			view:first-child {
				display: flex;
				align-items: center;

				.active {
					color: #C5F61C;
				}
			}

			view:last-child {
				display: flex;
				align-items: center;

				.active {
					color: #C5F61C;
				}
			}

			view {
				view {
					display: flex;
					align-items: center;

					view {
						margin-right: 10rpx;
					}
				}

				view:first-child {
					margin-right: 10rpx;
				}
			}
		}
	}
</style>
